package com.bleeth.flow.core.common;

import cn.hutool.core.text.StrBuilder;
import lombok.Getter;
import lombok.Setter;


public class FlowField implements Cloneable {

    @Setter
    @Getter
    private String field;

    @Setter
    @Getter
    private FieldType type;

    @Setter
    @Getter
    private String format;

    @Setter
    @Getter
    private String comment;


    public FlowField(String field) {
        this.field = field;
    }

    public FlowField(String field, FieldType type, String format, String comment ) {
        this.field = field;
        this.type = type;
        this.format = format;
        this.comment = comment;
    }

    public FlowField( ) {

    }
    //名称相同则判定是同一个flow
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (obj instanceof FlowField) {
            FlowField field = (FlowField) obj;
            String f = field.getField();
            if (f != null && f.equals(this.getField())) {
                return true;
            }
        }
        return false;
    }

    @Override
    protected FlowField clone() {
        FlowField model = null;
        try {
            return (FlowField) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return model;
    }

    @Override
    public String toString() {
        StrBuilder strBuilder = new StrBuilder();
        strBuilder.append("{");
        strBuilder.append("field").append(" = ").append(field).append(",");
        strBuilder.append("type").append(" = ").append(type).append(",");
        strBuilder.append("format").append(" = ").append(format).append(",");
        strBuilder.append("comment").append(" = ").append(comment);
        strBuilder.append("}");
        return strBuilder.toString();
    }
}
